home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20041116-20060924
/
000307_fdc@columbia.edu_Thu Apr 20 10:20:49 2006.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
3KB
Path: newsmaster.cc.columbia.edu!not-for-mail
From: Frank da Cruz <fdc@columbia.edu>
Newsgroups: comp.protocols.kermit.misc
Subject: Re: speed of script execution
Date: 20 Apr 2006 14:20:36 GMT
Organization: Columbia University
Lines: 54
Message-ID: <slrne4f65k.djh.fdc@sesame.cc.columbia.edu>
References: <1145524573.729587.320320@z34g2000cwc.googlegroups.com>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: sesame.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1145542836 11481 128.59.59.56 (20 Apr 2006 14:20:36 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 20 Apr 2006 14:20:36 GMT
User-Agent: slrn/0.9.8.0 (SunOS)
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15565
On 2006-04-20, tomviolin <rock_spambust_violin@yahoo.com> wrote:
: Can anyone tell me why there is such a huge time discrepency between
: the execution of the following scripts. The only difference is the
: curly braces. I'm running on an ARM SBC from a flash drive, if that
: makes any difference.
:
: ---- testx.ksc ----
: #!/usr/bin/kermit +
: { assign \%p 1, set line /dev/ttyAM\%p }
: { close }
: exit
:
: ---- testy.ksc ----
: #!/usr/bin/kermit +
: assign \%p 1, set line /dev/ttyAM\%p
: close
: exit
:
: -- test results --
: $ time ./testx.ksc
: real 0m 0.60s
: user 0m 0.04s
: sys 0m 0.06s
:
: $ time ./testy.ksc
: real 0m 0.09s
: user 0m 0.05s
: sys 0m 0.04s
:
: Yes, when I go back and forth between the two scripts, the times of
: each stay consistent, so the second one shown above didn't just run
: faster because it was second; if I go back and run testx.ksc again, it
: takes 0.60s.
:
: Of course "don't use the curly braces" but this is part of a larger
: system that I have distilled down to this very simple example, so
: that's really not an option.
:
As in C, the braces mark a block, entry to and exit from which carries some
setup and takedown cost. When you have only one or two statements in the
block, that cost is a lot higher, proportionally, than if you have a lot of
statements in it.
Block structure is a convenience and an aid to writing readable source code,
but it's not a necessity. Every block structure can be decomposed into
something more rudimentary and lest costly in execution, using GOTOs or
whatever. In fact, that's what happens internally anyway. The only
difference is that with true blocks, various buffers and variables and other
context have to be stacked.
If you have encountered a serious bottleneck in a real application, let me
know, maybe something can be done about it.
- Frank